﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.IO;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using Ookii.Dialogs.Wpf;

namespace TestWPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        public string LogFolderName
        {
            get { return logTextBox.Text; }

            set { logTextBox.Text = value; }
        }
        public string PatchFolderName
        {
            get { return patchTextBox.Text; }

            set { patchTextBox.Text = value; }
        }
        
        private void logButton_Click(object sender, RoutedEventArgs e)
        {

            Ookii.Dialogs.Wpf.VistaFolderBrowserDialog viewFolder = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog();

            if (viewFolder.ShowDialog() == true)
            {
                this.LogFolderName = viewFolder.SelectedPath;
                TestWPF.Settings1.Default.LogLocation = viewFolder.SelectedPath;
            }
        }

        private void patchButton_Click(object sender, RoutedEventArgs e)
        {
            Ookii.Dialogs.Wpf.VistaFolderBrowserDialog viewFolder = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog();

            if (viewFolder.ShowDialog() == true)
            {
                this.PatchFolderName = viewFolder.SelectedPath;
                TestWPF.Settings1.Default.PatchLocation = viewFolder.SelectedPath;
            }
        }

       
        private void patchFileButton_Click(object sender, RoutedEventArgs e)
            {
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

                Nullable<bool> result = dlg.ShowDialog();

                if (result == true)
                {
                    StreamReader streamReader = new StreamReader(dlg.FileName);
                    string text = streamReader.ReadToEnd();

                    // Create a FlowDocument to contain content for the RichTextBox.
                    FlowDocument myFlowDoc = new FlowDocument();

                    // Add paragraphs to the FlowDocument.

                    myFlowDoc.PageWidth = 1000;
                    myFlowDoc.Blocks.Add(new Paragraph(new Run(text)));

                   // RichTextBox myRichTextBox = new RichTextBox();

                    // Add initial content to the RichTextBox.
                    richTextBox1.Document = myFlowDoc;

                }
            }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            var newWindow = new EnterSettings();
            newWindow.Show();
        }

        
    }
}
